package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportRecordInspectionDto;
import com.yqg.protection.entity.RecordInspection;
import com.yqg.protection.mapper.RecordInspectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/15 11:10
 * description:
 */
@Component
public class RecordInspectionListener extends AnalysisEventListener<ImportRecordInspectionDto> {

    @Autowired
    private RecordInspectionMapper recordInspectionMapper;

    @Override
    public void invoke(ImportRecordInspectionDto importRecordInspectionDto, AnalysisContext analysisContext) {
        RecordInspection recordInspection = new RecordInspection();
        BeanUtil.copyProperties(importRecordInspectionDto, recordInspection, true);
        recordInspection.setIsDelete(0);
        recordInspectionMapper.insert(recordInspection);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
